package org.ttitfly.workflow.engine.assignment;

import org.ttitfly.workflow.SessionHolder;

/**
 * 默认任务分配，根据根据请求数据里指定的任务人进行分配
 * 
 * @author 潘海春
 * @version 2010-9-18
 */
public class DefaultAssignment implements Assignment {

	/**
	 * 默认请求数据中指定任务人的key
	 */
	public static final String DEFAULT_ASSIGNERS_KEY = "assigners";

	/**
	 * 请求数据中指定任务人的key
	 */
	private String assignersKey = DEFAULT_ASSIGNERS_KEY;

	/**
	 * 构造函数
	 * 
	 * @param assignersKey
	 */
	public DefaultAssignment(String assignersKey) {
		if (assignersKey != null && !("".equals(assignersKey))) {
			this.assignersKey = assignersKey;
		}
	}

	@Override
	public String[] assign() {
		String assigners = (String) SessionHolder.currentSession().getVariable(assignersKey);
		return assigners == null ? null : assigners.split(",");
	}
}
